/**
 * Created by LangK on 2016/12/20.
 */
require("./API/config.js");
var path = require('path')
var http = require("http");
var express = require('express')
var proxyMiddleware = require('http-proxy-middleware')
var bodyParser = require('body-parser')
require('body-parser-xml')(bodyParser)
var crypto = require('crypto')
var app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
  extended: false
}))
app.use(bodyParser.xml({
  limit: '2MB',
  xmlParseOptions: {
    normalize: true,
    normalizeTags: true,
    explicitArray: false
  }
}))
app.use(express.static(path.join(__dirname, '/dist/')))

// 代理
var proxyTable = {
  '/V1.0.0/api/newsControlApi': {
        target: "http://" + global.logIp + ":" + global.logport,
        changeOrigin: true
      }
}
Object.keys(proxyTable).forEach(function (context) {
  var options = proxyTable[context]
  if (typeof options === 'string') {
    options = { target: options }
  }
  app.use(proxyMiddleware(context, options))
})


app.listen(8000, function () {
  console.log('Server running at port:' + 8000);
});
